package br.com.Bolao.application.dao.jogos;

import br.com.Bolao.application.dao.BaseDAO;
import br.com.Bolao.model.Jogo;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.TransactionPropagationType;
import org.jboss.seam.annotations.Transactional;

/**
 *
 * @author frederico.cruz
 */
@AutoCreate
@Name("jogoDAO")
@Transactional(TransactionPropagationType.SUPPORTS)
public class JogoDAO extends BaseDAO{

    @In
    private Session bolao;

    public List<Jogo> obterTodos() {
        Criteria c = bolao.createCriteria(Jogo.class);
        return c.list();
    }

    public Jogo obterPorId(Integer idJogo) {
        Criteria c = bolao.createCriteria(Jogo.class);
        c.add(Restrictions.eq("idJogo", idJogo));
        return (Jogo) c.uniqueResult();
    }

    public Jogo obterPrimeiroJogo(){
        Criteria c = bolao.createCriteria(Jogo.class);
        return (Jogo) c.list().get(0);
    }
}
